<form nz-form nzLayout="inline">
  <nz-form-item>
    <nz-form-label
      nz-popover
      nzPopoverTitle="Automation"
      [nzPopoverContent]="autoInfoTemplate"
      >Auto
    </nz-form-label>
    <nz-form-control>
      <nz-input-group nzCompact>
        <nz-select
          [(ngModel)]="autoBuilding.autoBuyType"
          class="autoType"
          nzSize="small"
          [name]="autoBuilding.id + 'B'"
          (ngModelChange)="buildingAutoBuyChange()"
        >
          <nz-option
            nzLabel="Off"
            [nzValue]="BuildingAutoBuyTypes.OFF"
          ></nz-option>
          <nz-option
            nzLabel="Asap"
            [nzValue]="BuildingAutoBuyTypes.ASAP"
          ></nz-option>
          <nz-option
            nzLabel="As need"
            [nzValue]="BuildingAutoBuyTypes.AS_NEED"
          ></nz-option>
        </nz-select>
        <nz-select
          nzSize="small"
          class="autoTime"
          [(ngModel)]="autoBuilding.interval"
          [name]="autoBuilding.id + 'C'"
        >
          <nz-option
            *ngFor="let interval of INTERVALS; trackBy: getIntervalId"
            [nzLabel]="interval.label"
            [nzValue]="interval.value"
          ></nz-option>
        </nz-select>
      </nz-input-group>
    </nz-form-control>
  </nz-form-item>

  <nz-form-item
    *ngIf="autoBuilding.autoBuyType !== BuildingAutoBuyTypes.AS_NEED"
  >
    <nz-form-label
      nz-popover
      nzPopoverTitle="Max buy"
      nzPopoverContent="Buy up to 'max buy' at time. Works only with 'Asap' mode."
      >Max buy</nz-form-label
    >
    <nz-form-control>
      <nz-input-number
        nzSize="small"
        [name]="autoBuilding.id + 'M'"
        [(ngModel)]="autoBuilding.maxBuy"
      ></nz-input-number>
    </nz-form-control>
  </nz-form-item>

  <nz-form-item>
    <nz-form-label
      nz-popover
      nzPopoverTitle="Priority"
      nzPopoverContent="In case more auto buyer are available on the same update cycle, high priority execute first."
      >Priority
    </nz-form-label>
    <nz-form-control>
      <nz-input-number
        nzSize="small"
        [name]="autoBuilding.id + 'P'"
        [(ngModel)]="autoBuilding.priority"
      ></nz-input-number>
    </nz-form-control>
  </nz-form-item>
</form>

<ng-template #autoInfoTemplate>
  Options:
  <ul>
    <li>On / Off, Type</li>
    <li>Interval</li>
  </ul>
</ng-template>
